<%@ page language="java" import="java.util.*,com.hanma.bean.Category" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<%
	String pid = request.getAttribute("pid").toString();
	Category cate = (Category)request.getAttribute("cate");
%>
<div>
	<a href="cateadd.do?pid=<%=pid%>">添加分类</a>
</div>
<table  border="1" align="center" cellspacing="0" cellpadding="0" width="600">
    <tr align="center" height="50" width="600">
        <td colspan="8">分类列表</td>
    </tr>
    <tr align="center" height="50">
        <td>ID</td>
        <td>分类名称</td>
        <td>所属分类</td>
        <td>状态</td>
        <td>操作</td>
    </tr>

    <%
        List<Category> cateList = (List<Category>)request.getAttribute("cateList");
    	if(cateList != null && cateList.size() > 0){
    		for(Category category : cateList){
    			
    %>
    <tr>
        <td><%= category.getId()%></td>
        <td><%= category.getName()%></td>
        <td><%= category.getPid()==0?"一级分类":cate.getName()%></td>
        <td><%= category.getStatus()==1?"正常":"禁止"%></td>
        <%
            if(category.getPid() == 0){
        %>
        <td>
        	<a  href="catelist.do?pid=<%= category.getId()%>">子类管理</a>
            <a  href="cateupdate.do?id=<%= category.getId()%>">修改</a>
            <a  href="catedelete.do?id=<%= category.getId()%>">删除</a>
        </td>
        <%
            }
            else{
        %>
        <td>
            <a  href="catelist.do?pid=0">返回上一级</a>
            <a  href="cateupdate.do?id=<%= category.getId()%>">修改</a>
            <a  href="catedelete.do?id=<%= category.getId()%>">删除</a>
            <a  href="#">新闻详情</a>
        </td>
        <%
            }
        %>
    </tr>
     <%
    		}
    	}
     %>
</table>
</body>
</html>